<?php @session_start();?>
<?php
require_once('./safe.php');
require_once('../admin/config.php');
$conn = mysql_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd);
mysql_select_db($cfg_dbname,$conn);
$sql="select * from ph_user where user_name='".$_SESSION["username"]."'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$Balance=$row["balance"];

$ID_Dele=implode(",",$_POST['order_id']);

$sqls="select * from ph_order where Status='Pending' and id in(".$ID_Dele.")";
$results=mysql_query($sqls);
while($rows=mysql_fetch_array($results)){
    $Balance=$Balance+$rows["Price"];
    $sqle = "INSERT INTO ph_transactions(Transaction_ID,Amount,Payment_Amount,payType,cdate,userid)VALUES('".$rows["orderno"]."','".$Balance."','+".$rows["Price"]."','Return balance','".date('Y-m-d H:i:s',time())."','".$_SESSION["userid"]."')";
            mysql_query($sqle,$conn);

$sqld = "update ph_user set balance=balance+".$rows["Price"]." where id='".$_SESSION["userid"]."'";
mysql_query($sqld,$conn);
}

$sqla = "delete from ph_order where Status='Pending' and id in(".$ID_Dele.")";
mysql_query($sqla,$conn);



?>